Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Scripting Additions Guide /
Chapter 2 - Scripting Addition Commands / Command Definitions
/


Store Script

The Store Script command stores a specified script object in a specified file. It is the only command provided by the Store Script scripting addition.

SYNTAX
store script scriptObjectVariable                     ¬
   [in referenceToFile ]                                 ¬
   [ replacing replacementOption ]
PARAMETERS
scriptObjectVariable
The name of a script object declared previously in the
same script.
Class: Script

referenceToFile
A reference of the form file nameString or alias nameString (see "Notes"). If this parameter is omitted, Store Script displays a directory dialog box and requests that the user choose a file in which to store the script.
Class: Reference

replacementOption
One of the constants ask, yes, or no. The constant ask causes the Store Script command to display a dialog box asking the user whether to overwrite the file specified by scriptObjectVariable, rename it, or cancel the operation. (Displaying this dialog box is the default if the replacing parameter is omitted.) The constant yes indicates that you want Store Script to replace the file, and the constant no indicates that you do not want Store Script to replace the file if it already exists.
Class: String
RESULT
None

EXAMPLES
This script object is used in the examples that follow:

script DemoStore
   property Red: 127
   property Green : 128
   property Blue : 127
   on returnRGB()
      return Red & Green & Blue
   end return
end script
This example stores the script object DemoStore in a file called Store My RGB:

store script DemoStore in file ¬
   "My HD:Some Folder:Store My RGB" replacing yes
The replacing yes parameter indicates that Store Script should overwrite the existing file.

Later statements in the same script like the following load the stored script object DemoStore, change one of its properties, and store it to disk again:

set objRef to load script ¬
   file "My HD:Some Folder:Store My RGB" 
set objRef's Red to 250
store script objRef ¬
   in file "My HD:Some Folder:Store My RGB"
In this case the replacing parameter is omitted, so Store Script displays a dialog box asking the user whether to overwrite the file, rename it, or cancel the operation.

NOTES
To specify the name (nameString) of a file, use a string of the form "Disk:Folder1:
Folder2:...:Filename"
as described in Chapter 5, "Objects and References,"
of the AppleScript Language Guide. If you specify only the name of the file (Filename) instead of its entire pathname, AppleScript attempts to find the file in the current directory.

ERRORS
Error
number
Error message
-108Out of memory.
-128User canceled.
-192Bad name for file.
-1700Can't make some data into the expected type.
-1701Some parameter is missing for <commandName>.
-1704Some parameter was invalid.
-1705Operation involving a list item failed.
-1708<reference> doesn't understand the <commandName> message.
-1718Reply has not yet arrived.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
18 DEC 1996